package VIEW;

import CONF.ConexaoOracle;
import MODEL.LineUpModel;
import MODEL.RockInRio;
import java.sql.Connection;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;


public class RelatoriosView extends javax.swing.JFrame {
    
    private ArrayList<LineUpModel> lineUpArray;
    

    /**
     * Creates new form ConfirmacaoView
     * @param dados
     */
    public RelatoriosView() {
        ConexaoOracle conOracle;
        Connection con;
        
        initComponents();
        
        conOracle = new ConexaoOracle();
        con = ConexaoOracle.conectar();
        
        RockInRio rir = new RockInRio();
        try {
            lineUpArray = rir.getLineUpsDB(ConexaoOracle.conexao);
        } catch (SQLException ex) {
            Logger.getLogger(RelatoriosView.class.getName()).log(Level.SEVERE, null, ex);
        }
        
        for(LineUpModel lineUp : lineUpArray) {
            try {
                lineUp.relatarIngressos(ConexaoOracle.conexao);
            } catch (SQLException ex) {
                System.out.println(ex.getMessage());
            }
            textoInformacoes.append(lineUp.calendarToDataString(lineUp.getData()) + "\n");
            textoInformacoes.append("------------------\n");
            textoInformacoes.append("Total de ingressos: " + lineUp.getTotalIngressos() + "\n");
            textoInformacoes.append("Total de ingressos vendidos: " + lineUp.getTotalVendidos() + "\n");
            textoInformacoes.append("Total de espectadores presentes: " + lineUp.getTotalPresentes() + "\n");
            textoInformacoes.append("Porcentagem de ingressos vendidos e utilizados: " + lineUp.getPorcVendidosUsados() + "\n");
            textoInformacoes.append("Porcentagem de ingressos vendidos e não utilizados: " + lineUp.getPorcVendidosNaoUsados() + "\n");
            textoInformacoes.append("Porcentagem de ingressos não vendidos: " + lineUp.getPorcNaoVendidos() + "\n");
            textoInformacoes.append("\n");
        }
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        painelConfirmacao = new javax.swing.JPanel();
        labelTitulo = new javax.swing.JLabel();
        botaoVoltar = new javax.swing.JButton();
        painelInformacoes = new javax.swing.JScrollPane();
        textoInformacoes = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Relatório de Ingressos");

        labelTitulo.setText("Relatório de Ingressos");

        botaoVoltar.setText("Voltar");
        botaoVoltar.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botaoVoltarActionPerformed(evt);
            }
        });

        textoInformacoes.setColumns(20);
        textoInformacoes.setRows(5);
        textoInformacoes.setDisabledTextColor(new java.awt.Color(0, 0, 0));
        textoInformacoes.setEnabled(false);
        painelInformacoes.setViewportView(textoInformacoes);

        javax.swing.GroupLayout painelConfirmacaoLayout = new javax.swing.GroupLayout(painelConfirmacao);
        painelConfirmacao.setLayout(painelConfirmacaoLayout);
        painelConfirmacaoLayout.setHorizontalGroup(
            painelConfirmacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelConfirmacaoLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(painelConfirmacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(painelInformacoes, javax.swing.GroupLayout.DEFAULT_SIZE, 488, Short.MAX_VALUE)
                    .addGroup(painelConfirmacaoLayout.createSequentialGroup()
                        .addGroup(painelConfirmacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(botaoVoltar)
                            .addComponent(labelTitulo))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );
        painelConfirmacaoLayout.setVerticalGroup(
            painelConfirmacaoLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(painelConfirmacaoLayout.createSequentialGroup()
                .addContainerGap()
                .addComponent(labelTitulo)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(painelInformacoes, javax.swing.GroupLayout.PREFERRED_SIZE, 268, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(18, 18, 18)
                .addComponent(botaoVoltar)
                .addContainerGap())
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painelConfirmacao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(painelConfirmacao, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );

        painelConfirmacao.getAccessibleContext().setAccessibleName("painelConfirmacao");

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botaoVoltarActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botaoVoltarActionPerformed
        this.dispose();
        EscolhaView escolhaView = new EscolhaView();
        escolhaView.setLocationRelativeTo(null);
        escolhaView.setVisible(true);
    }//GEN-LAST:event_botaoVoltarActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        /* Set the Nimbus look and feel */
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
                if ("Nimbus".equals(info.getName())) {
                    javax.swing.UIManager.setLookAndFeel(info.getClassName());
                    break;
                }
            }
        } catch (ClassNotFoundException ex) {
            java.util.logging.Logger.getLogger(RelatoriosView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (InstantiationException ex) {
            java.util.logging.Logger.getLogger(RelatoriosView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            java.util.logging.Logger.getLogger(RelatoriosView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        } catch (javax.swing.UnsupportedLookAndFeelException ex) {
            java.util.logging.Logger.getLogger(RelatoriosView.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
        }
        //</editor-fold>

        /* Create and display the form */
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new RelatoriosView().setVisible(true);
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botaoVoltar;
    private javax.swing.JLabel labelTitulo;
    private javax.swing.JPanel painelConfirmacao;
    private javax.swing.JScrollPane painelInformacoes;
    private javax.swing.JTextArea textoInformacoes;
    // End of variables declaration//GEN-END:variables
}
